'''
@Company: TWL
@Author: xue jian
@Email: xuejian@kanzhun.com
@Date: 2020-04-07 10:25:33
'''

#nohup python -u direct_deal.py > direct_result 2>&1 &
import math

# dates = ["2020-03-30", "2020-03-31", "2020-04-01", "2020-04-02", "2020-04-03", "2020-04-04", "2020-04-05"]
dates = ["2020-08-24", "2020-08-25", "2020-08-26", "2020-08-27", "2020-08-28", "2020-08-29", "2020-08-30"]
for date in dates:
    input_path_ori = date + "/boss_exposure_geek_actice_time_"
    # print input_path
#    out_path = date + "/boss_cp_exp_active_time_pm"
    out_path_ori = date + "/boss_cp_geek_active_time_"
    # print out_path
    for tmp in ['am', 'pm']:
        input_path = input_path_ori + tmp
        out_path = out_path_ori + tmp
        print(input_path, out_path)
        ff = open(out_path, 'w')

        with open(input_path, 'r') as f:
            for line in f:
                lineArr = line.split('\t')
                # geek active time
                dist = lineArr[2].replace('[', '').replace(']', '')
                # exp active time
    #            dist = lineArr[3].replace('[', '').replace(']', '')
                dist_arr = dist.split(',')

                interval = (int(math.ceil(float(dist_arr[-3]))))
                ff.write(lineArr[0] + '\t' + lineArr[1] + '\t' + str(interval) + '\n')

        ff.close()